
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
cast-to-array
Advanced tools
Cast a value to an array.
Install with npm
$ npm i cast-to-array --save
var arrayify = require('cast-to-array');
returns an empty array when value is null or undefined
arrayify(null);
arrayify(undefined);
//=> []
casts a non-array value to an array
arrayify('abc');
//=> ['abc']
arrayify(/xyz/);
//=> [/xyz/]
arrayify(new RegExp('.'));
//=> [new RegExp('.')]
arrayify([[]]);
//=> [[]]
arrayify({});
//=> [{}]
returns an array directly
arrayify(['foo']);
//=> ['foo']
arrayify([]);
//=> []
[].map(f)
for older browsers | homepageInstall dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on November 06, 2015.
FAQs
Cast a value to an array.
The npm package cast-to-array receives a total of 2 weekly downloads. As such, cast-to-array popularity was classified as not popular.
We found that cast-to-array demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.